# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


# 个人信息
class XhsSpiderItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    nickname = scrapy.Field()
    red_id = scrapy.Field()
    fans = scrapy.Field()
    follows = scrapy.Field()
    describ = scrapy.Field()
    gender = scrapy.Field()
    userid = scrapy.Field()
    collect_like = scrapy.Field()
    ndiscovery = scrapy.Field() # 笔记总数
    user_logo = scrapy.Field()
    user_url = scrapy.Field()
    def save_to_mysql(self):

        sql='insert into xhs_info(nickname,red_id,fans,follows,describ,gender,userid,collect_like,ndiscovery,user_logo,user_url)' \
            'values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'

        data=(self["nickname"],self["red_id"],self["fans"],self["follows"],self["describ"],self["gender"],self['userid'],self["collect_like"],self["ndiscovery"],self["user_logo"],self["user_url"],)

        return sql,data

# 笔记的信息
class NoteItem(scrapy.Item):
    note_userid = scrapy.Field()
    note_id = scrapy.Field()
    note_title = scrapy.Field()
    fav_count = scrapy.Field()
    likes = scrapy.Field()
    comment_count = scrapy.Field()

    def save_to_xhs_note(self):
        sql = 'insert into xhs_note(note_userid,note_id,note_title,fav_count,likes,comment_count)' \
              'values (%s,%s,%s,%s,%s,%s)'
        data = (self["note_userid"],self["note_id"],self["note_title"],self["fav_count"],self["likes"],self["comment_count"])

        return sql,data